import { defineConfig } from 'vite'
import { join } from 'path'

import vue from '@vitejs/plugin-vue'
/**
 * 服务端渲染不能使用按需加载
 */
// import AutoImport from 'unplugin-auto-import/vite'
// import Components from 'unplugin-vue-components/vite'
// import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
// https://vitejs.dev/config/
export default defineConfig({
  // element 自动导入
  plugins: [
    vue()
    // AutoImport({
    //   resolvers: [ElementPlusResolver()]
    // }),
    // Components({
    //   resolvers: [ElementPlusResolver()]
    // })
  ],
  // 软连接
  resolve: {
    alias: {
      '@': join(__dirname, '/src'),
      components: join(__dirname, '/src/components'),
      constants: join(__dirname, '/src/constants'),
      api: join(__dirname, '/src/api'),
      libs: join(__dirname, '/src/libs'),
      router: join(__dirname, '/src/router'),
      store: join(__dirname, '/src/store'),
      utils: join(__dirname, '/src/utils'),
      vendor: join(__dirname, '/src/vendor'),
      views: join(__dirname, '/src/views'),
      assets: join(__dirname, '/src/assets')
    }
  },
  // sass 配置
  css: {
    preprocessorOptions: {
      scss: {
        additionalData:
          '@import "@/assets/style/variable.scss";@import "@/assets/style/main.scss";'
      }
    }
  }
})
